import axios from "~/axios";
import { queryParams } from '~/composables/util.js'

//获取商品
export function getMGoodsList(page,query = {}){

  let r = queryParams(query)

  return axios.get(`/admin/goods/${page}${r}`)
}

//修改商品状态（批量上/下架）
export function updateGoodsStatus(ids,status){  
  return axios.post(`/admin/goods/changestatus`,{ids,status})
}

//新增商品
export function createGoods(data){  
  return axios.post(`/admin/goods`,data)
}
//修改商品
export function updateGoods(id,data){  
  return axios.post(`/admin/goods/${id}`,data)
}
//批量删除商品
export function deleteGoods(ids){  
  return axios.post(`/admin/goods/delete_all`,{ids})
}

//轮播图 /admin/goods/read/:id   /admin/goods/banners/:id
export function readGoods(id){
  return axios.get(`/admin/goods/read/${id}`)
}

export function setGoodsBanner(id,data){
  return axios.post(`/admin/goods/banners/${id}`,data)
}

//添加详情
export function updateGoodsSkus(id,data){  
  return axios.post(`/admin/goods/updateskus/${id}`,data)
}

export function createGoodsSkusCard(data){  
  return axios.post(`/admin/goods_skus_card`,data)
}

//修改商品规格选项  /admin/goods_skus_card/:id
export function updateGoodsSkusCard(id,data){  
  return axios.post(`/admin/goods_skus_card/${id}`,data)
}

//删除商品规格选项 
export function deleteGoodsSkusCard(id){  
  return axios.post(`/admin/goods_skus_card/${id}/delete`)
}